home *** CD-ROM | disk | FTP | other *** search
- ////////////////////////////////////////////////////////////////////
- // vf3.js Version 2 (August 19th, 1999)
- // -----------------------------------------------------------------
- // (c) 1999 Haptek, Inc.
-
-
- ////////////////////////////////////////////////////////////////////
- // Function QuickRef
- // -----------------------------------------------------------------
- // (parameters surrouned by braces, [], are optional)
- // See the note below about the 'code' parameter.
- //
- //
- // SendText(text[,box]) - sends 'text' to hypertext interpreter of plugin
- // HapQuery(text[,box]) - ditto w/ query
- // VFBoxSelect(box) - selects a plugin instance to send commands to
- // VFBox(x, y[,commandfile]) - draws a box on the page x by y. Optionaly a local command file can be included
- // UseVFE(DLFN, code) - downloads and loads a VFE (if code is not specified, loads a local file, see src)
- // UseFile(DLFN, code) - ditto , w/ file
- // UseBackground(DLFN, code) - ditto w/ background
- // UseTexture(DLFN, code) - ditto w/ texture
- // UseMorph(morph [, code]) - ditto w/ morph If no code, then uses a standard morph. Downloading not tested!
- // UseNaturalVoice(DLFNwav, DLFNphn, code) - ditto w/ sound and phn file.
- // StartFile(thefile) - performs the \start hypertext command on 'thefile'
- // GrabFile(DLFN, code) - downloads a file (good for putting things in cache)
- // CleanUp([box]) - performs the \cleanup hypertext command
- // SetMaterial(i0, f0, f1, f2, f3) - changes material i0 w/ the f* values
- // SetAmbient(r, g, b, a) -
- // SetDiffuse(r, g, b, a) -
- // SetEmissive(r, g, b, a) -
- // SetSpecular(r, g, b, a) -
- // SetSpecularPower(power) -
- // Rotate(x, y, z, t) - just like the hypertext
- // Translate(x, y, z, t) - just like the hypertext
- // AddInitFile(box, name) - adds a scene file to be loaded to the vf 'box' as soon as the page is loaded
- // AddToInitQueue(string[,box]) - adds a string of javascript to be eval'ed as soon as the plugin is ready.
- // HAPOnLoadInit() - function that must be put in the <BODY onLoad=> tag
- //
- // About the 'code' parameter:
- //
- // 'code' is a way of specifying what sort of filename you have passed to
- // the downloading functions:
- // 'R' Filename is relative to current webpage (ex: mybackground.jpg)
- // 'A' Absolute URL or filename (ex: http://www.haptek.com/texture/tex.jhp)
- // 'DB1' DB1 is a repository of most of Haptek's textures (ex: head/mapBaba512.jhp)
-
- function SendText(text, box)
- {
- // check if optional parameter was passed
- if(box) boxofchoice = box;
- else boxofchoice = G_PluginCurrent;
-
- if(G_PluginOkay) {
- var shortText = text.substr(0, 1400);
- if(G_BrowserNavigator)
- eval("document.embeds['"+G_VFBoxes[boxofchoice].name+"'].HyperText(shortText);");
- if(G_BrowserExplorer)
- eval("document."+G_VFBoxes[boxofchoice].name+".HyperText = shortText;");
- }
- if(G_Debugger)
- window.document.debug.outputbox.value = shortText + "\n" + window.document.debug.outputbox.value;
- }
-
- function HapQuery(text, box)
- {
- // check if optional parameter was passed
- if(box) boxofchoice = box;
- else boxofchoice = G_PluginCurrent;
-
- rtn = "";
- if(G_PluginOkay) {
- var shortText = text.substr(0, 1400);
- if(G_BrowserNavigator)
- eval("rtn = document.embeds['"+G_VFBoxes[boxofchoice].name+"'].QueryPlugin(shortText);");
- if(G_BrowserExplorer)
- {
- eval("document."+G_VFBoxes[boxofchoice].name+".Query = shortText;");
- eval("rtn = document."+G_VFBoxes[boxofchoice].name+".Query");
- }
- }
- if(G_Debugger)
- window.document.debug.outputbox.value = "A: " + rtn + "\nQ: " +shortText +"\n"+ window.document.debug.outputbox.value;
- return rtn;
- }
-
- function VFBoxSelect(box)
- {
- G_PluginCurrent = box;
- }
-
- function VFBox(x, y, commandfile)
- {
- G_PluginNum++;
- G_VFBoxes[G_PluginNum] = new Object();
- G_VFBoxes[G_PluginNum].name = "vfbox" + G_PluginNum;
- G_VFBoxes[G_PluginNum].path = 'document';
- G_VFBoxes[G_PluginNum].sizex = x;
- G_VFBoxes[G_PluginNum].sizey = y;
-
- // exception to start the version testing
- if(G_PluginNum == 1) AddToInitQueue("SafeQuery();");
-
- // check to see if an external command file is specified
- if (commandfile)
- G_VFBoxes[G_PluginNum].scene = JustFile(commandfile);
- else
- G_VFBoxes[G_PluginNum].scene = 'data\\standard\\standardStartup.hap';
-
-
-
- if (G_PluginOkay)
- {
-
- if (G_BrowserNavigator)
- {
- document.write("<EMBED type=\""+G_HAPMimeType+"\" name=\""+ G_VFBoxes[G_PluginNum].name+"\" width=\""+x+"\" height=\""+y+"\" border= \"0\" vspace= \"0\" hspace=\"0\"></EMBED>");
- }
- else
- {
- document.write("\
- <OBJECT id=\""+ G_VFBoxes[G_PluginNum].name + "\" classid=\""+G_HAPCLSID+"\"\
- align=\"baseline\" border=\"0\" width=\""+x+"\" height=\""+y+"\">\
- </OBJECT>\
- ");
- }
- }
- else
- {
- if(G_NoVF3Image)
- {
- document.write("<img src="+G_NoVF3Image+" WIDTH="+x+" HEIGHT="+y+">");
- }
- else
- {
- document.write("<table width="+x+" height="+y+" border=2 bordercolor=\"#0000ee\"><tr><td><font size=-1>");
- document.write("╖╟│ú▒º╟╕ú¼─·╨Φ╥¬ VirtualFriend 3 ╡─╫ε╨┬░µ▒╛╥╘▒π╘┌╒Γ└∩Σ»└└ VirtualFriend ╫╓╖√íú╚τ╣√─·╡Ñ╗≈<a href=\"http://vf3.haptek.com\">╒Γ└∩</a>ú¼─·┐╔┤╙ Haptek, Inc ╧┬╘╪╦ⁿíú");
- document.write("</font></td></tr></table>");
- }
- }
-
- VFBoxSelect(G_PluginNum);
-
- if(commandfile == "none") return;
-
- if(commandfile)
- {
- commandfile = Backslashify(commandfile);
- selectbox = "VFBoxSelect("+G_PluginNum+");"
- usefile = "UseFile('"+commandfile+"', 'A');";
- AddToInitQueue(selectbox);
- AddToInitQueue(usefile);
- }
- else
- {
- AddToInitQueue("SendText('\\\\load [file= "+G_HAP_LangScene+"]')");
- AddToInitQueue("SendText('\\\\load [file= "+G_HAP_LangPose+"]')");
- }
-
-
-
- }
-
- function UseVFE(DLFN, code)
- {
- UseFile(DLFN, code);
- }
-
- function UseFile(DLFN, code)
- {
- if(code)
- {
- if (code == "A" )
- DLURL = "" + DLFN;
- else if (code == "R" )
- DLURL = G_PageRoot + DLFN;
- else if (code == "DB1" )
- DLURL = G_DB1 + DLFN;
-
- fn = JustFile(DLFN);
- grp = GetGrp();
-
- SendText("\\setgrouphypertext[action= [\\load [file= ["+fn+"]]] i0= "+grp+"]");
- SendText("\\setcachedownload[file= ["+DLURL+"] i0= "+grp+"]");
- SendText("\\startcachedownload[i0= "+grp+"]");
- }
- else
- {
- SendText("\\load [file= ["+DLFN+"]]");
- }
- }
-
- function UseBackground(DLFN, code)
- {
- if(code)
- {
- if (code == "A" )
- DLURL = "" + DLFN;
- else if (code == "R" )
- DLURL = G_PageRoot + DLFN;
- else if (code == "DB1" )
- DLURL = G_DB1 + DLFN;
-
- fn = JustFile(DLFN);
- grp = GetGrp();
-
- CleanUp();
- SendText("\\setgrouphypertext[action= [ \\loadbackgrnd [file= ["+fn+"]]] i0= "+grp+"]");
- SendText("\\setcachedownload[file= ["+DLURL+"] i0= "+grp+"]");
- SendText("\\startcachedownload[i0= "+grp+"]");
- }
- else
- {
- SendText("\\loadbackgrnd [file= ["+DLFN+"]]");
- }
- }
-
- function UseTexture(DLFN, code)
- {
- if(code)
- {
- if (code == "A" )
- DLURL = "" + DLFN;
- else if (code == "R" )
- DLURL = G_PageRoot + DLFN;
- else if (code == "DB1" )
- DLURL = G_DB1 +DLFN;
-
- fn = JustFile(DLFN);
- grp = GetGrp();
-
-
- CleanUp();
- SendText("\\setgrouphypertext[action= [ \\settexture [tex= ["+fn+"]]] i0= "+grp+"]");
- SendText("\\setcachedownload[file= ["+DLURL+"] i0= "+grp+"]");
- SendText("\\startcachedownload[i0= "+grp+"]");
- }
- else
- {
- SendText("\\settexture[tex= ["+DLFN+"]]");
- }
- }
-
- function UseMorph(DLFN, code)
- {
- if(code)
- {
- if (code == "A" )
- DLURL = "" + DLFN;
- else if (code == "R" )
- DLURL = G_PageRoot + DLFN;
- else if (code == "DB1" )
- DLURL = G_DB1 + DLFN;
-
- fn = JustFile(DLFN);
- grp = GetGrp();
-
- SendText("\\setgrouphypertext[action= [\\load [file= ["+fn+"]]] i0= "+grp+"]");
- SendText("\\setcachedownload[file= ["+DLURL+"] i0= "+grp+"]");
- SendText("\\startcachedownload[i0= "+grp+"]");
- }
- else
- {
- SendText("\\setmorph[state="+DLFN+"]");
- }
- }
-
- function UseNaturalVoice(DLFNwav, DLFNphn, code)
- {
- if (code == "A" ){
- DLURLwav = "" + DLFNwav;
- DLURLphn = "" + DLFNphn;}
- else if (code == "R" ){
- DLURLwav = G_PageRoot + DLFNwav;
- DLURLphn = G_PageRoot + DLFNphn;}
- else if (code == "DB1" ){
- DLURLwav = G_DB1 + DLFNwav;
- DLURLphn = G_DB1 + DLFNphn;}
-
- fnwav = JustFile(DLFNwav);
- fnphn = JustFile(DLFNphn);
- grp = GetGrp();
-
- SendText("\\setgrouphypertext[action= [\\load [file= ["+fnphn+"]] \\start [file=["+fnphn+"]] ] i0= "+grp+"]");
- SendText("\\setcachedownload[file= ["+DLURLwav+"] i0= "+grp+"]");
- SendText("\\setcachedownload[file= ["+DLURLphn+"] i0= "+grp+"]");
- SendText("\\startcachedownload[i0= "+grp+"]");
-
- }
-
- function StartFile(thefile)
- {
- fn = JustFile(thefile);
-
- SendText("\\start [file= ["+fn+"]]");
- }
-
- function LoadFile(thefile)
- {
- fn = JustFile(thefile);
-
- SendText("\\load [file= ["+fn+"]]");
- }
-
- function GrabFile(DLFN, code)
- {
- if (code == "A" )
- DLURL = "" + DLFN;
- else if (code == "R" )
- DLURL = G_PageRoot + DLFN;
- else if (code == "DB1" )
- DLURL = G_DB1 + DLFN;
-
- fn = JustFile(DLFN);
- grp = GetGrp();
-
-
- SendText("\\setcachedownload[file= ["+DLURL+"] i0= "+grp+"]");
- SendText("\\startcachedownload[i0= "+grp+"]");
- }
-
-
- function CleanUp(box)
- {
- // if the box parameter is passed, it will be chosen
- if(box) VFBoxSelect(box);
- SendText('\\cleanup');
- }
-
- //////////////////////////////////////////////////////////////
- // Material Properties
- // i0 == 0 Ambient
- // i0 == 1 Diffuse
- // i0 == 2 Emissive
- // i0 == 3 Specular
- // i0 == 4 Specular Power
- function SetMaterial(i0, f0, f1, f2, f3)
- {
- SendText("\\setmaterial[i0= " + i0 + " r= " + f0 + " g= " + f1 +" b= " + f2 + " a= " + f3 + " ]");
- }
-
- function SetAmbient(r, g, b, a)
- {
- SetMaterial(0, r, g, b, a);
- }
-
- function SetDiffuse(r, g, b, a)
- {
- SetMaterial(1, r, g, b, a);
- }
-
- function SetEmissive(r, g, b, a)
- {
- SetMaterial(3, r, g, b, a);
- }
-
- function SetSpecular(r, g, b, a)
- {
- SetMaterial(2, r, g, b, a);
- }
-
- function SetSpecularPower(power)
- {
- SetMaterial(4, power, power, power, power);
- }
-
- function Rotate(x, y, z, t)
- {
- SendText("\\rotate[ x="+x+" y="+y+" z="+z+" t="+t+"]");
- }
-
-
- function Translate(x, y, z, t)
- {
- SendText("\\translate[ x="+x+" y="+y+" z="+z+" t="+t+"]");
- }
-
- function AddInitFile(box, name)
- {
- var loadtext = '\\load [file= '+name+']';
-
- var load = Backslashify('SendText(\''+loadtext+'\');');
- var set = Backslashify('VFBoxSelect('+box+');');
-
- G_HAPInitCommands[G_HAPInitCommandsIndex++]=set;
- G_HAPInitCommands[G_HAPInitCommandsIndex++]=load;
- }
-
- function AddToInitQueue(string, box)
- {
- // if a box is selected, it will remain selected after this command
- if(box) G_HAPInitCommands[G_HAPInitCommandsIndex++]='VFBoxSelect('+box+');';
- G_HAPInitCommands[G_HAPInitCommandsIndex++]=string;
- }
-
- function HAPOnLoadInit()
- {
- G_HAPInitInterval = setInterval('HAPOnLoadInit_hidden();', G_HAPInitIntervalTime);
- }
-
- ///////////////////////////////////////////////////////////////////////
- // EVERYTHING BELOW THIS BOX IS NOT USEFUL TO A WEB DESIGNER //
- ///////////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////////
- // HAPOnLoadInit_hidden()
- // HEY! Don't look at this function =), it's called by HAPOnLoadInit()
- // It evaluates the onload javascript functions
-
- function HAPOnLoadInit_hidden()
- {
- clearInterval(G_HAPInitInterval);
-
- for(i = 0; i <= G_HAPInitCommandsIndex; i++)
- {
- eval(G_HAPInitCommands[i]);
- }
- }
-
- //////////////////////////////////////////////////////////////
- // These are assistant functions
-
- function GetGrp()
- {
- G_GrpNum++;
- if (G_GrpNum > G_GrpMax)
- G_GrpNum = 1;
- return G_GrpNum;
- }
-
- function JustPath(s)
- {
- delimit = "/";
- sa = s.split(delimit);
- rtn = "";
- for (i = 0; i < sa.length - 1; i++)
- rtn = rtn + sa[i] + delimit;
- return rtn;
- }
-
- function JustFile(s)
- {
- delimit = "/";
- sa = s.split(delimit);
- if (sa.length > 0)
- rtn = sa[sa.length - 1];
- else
- rtn = s;
- return rtn;
- }
-
- function Backslashify(s)
- {
- // Regular Expression to globaly match '\'
- re = /\\/gi
-
- // Replace / with //
- rtn = s.replace(re, '\\\\');
-
- return rtn;
- }
-
- function SafeQuery()
- {
- // G_SafeQuery == 0 if there is no plugin
- // 1 if the plugin is old
- // the version of the plugin if it has querying
-
- if(G_BrowserNavigator)
- {
- if(document.embeds['vfbox1'])
- {
- found = false;
- for(tootoo in document.embeds['vfbox1'])
- {
- if(tootoo == "QueryPlugin")
- {
- found = true;
- break;
- }
- }
-
- if(!found)
- {
- G_SafeQuery = "0";
- return(false);
- }
- else
- {
- G_SafeQuery = HapQuery("release", 1);
- return(true);
- }
-
- found = false;
- for(tootoo in document.embeds['vfbox1'])
- {
- if(tootoo == "HyperText")
- {
- G_SafeQuery = "1";
- break;
- }
- }
-
- }
- else
- {
-
- G_SafeQuery = "0";
- return(false);
- }
- }
- if(G_BrowserExplorer)
- {
- if(document.vfbox1)
- {
- blah = HapQuery("release", 1);
-
- if(blah == "release")
- {
- for(tootoo in document.vfbox1)
- {
- if(tootoo == "HyperText")
- {
- G_SafeQuery = "1";
- break;
- }
- }
- if(G_SafeQuery != "1") G_SafeQuery = "0";
- return(false);
- }
- else G_SafeQuery = blah;
- }
- else
- {
- G_SafeQuery = "0";
- return(false);
- }
- }
- return(true);
- }
-
- <!--
- /////////////////////////
- // Global Variables
- /////////////////////////
- var G_DownloadName = "VirtualFriend 3";
- var G_Platform = "Win32";
- var G_PlatformOkay = true;
- var G_BrowserExplorer = false;
- var G_BrowserNavigator = false;
- var G_BrowserVersion = "0.0";
- var G_BrowserOkay = false;
- var G_BrowserWhyNot = "javascript │÷╧╓╣╩╒╧íú";
- var G_PluginOkay = false;
- var G_PluginWhyNot = "─·├╗╙╨░▓╫░ " + G_DownloadName + "íú";
- var G_PluginName = "VirtualFriend Plugin";
- var G_PluginNameOld = "HelloWorld Example Plugin";
- var G_ErrorHandlerOrig = null;
- var G_PluginNum = 0;
- var G_PluginCurrent = 0;
- var G_PageRoot = JustPath(document.location.toString());
- var G_DB1 = "http://www.haptek.com/db1/";
- var G_GrpNum = 1;
- var G_GrpMax = 100;
- var G_VFBoxes = new Array;
- var G_VFBoxSizeX = 150;
- var G_VFBoxSizeY = 150;
- var G_Debugger = false;
- var G_SafeQuery = "0";
- var G_HAPInitInterval;
- var G_HAPInitIntervalTime = 2000;
- var G_HAPInitCommands = new Array;
- var G_HAPInitCommandsIndex = 0;
- var G_HAP_LangPose = "data\\\\standard\\\\standardPose.hap";
- var G_HAP_LangScene = "data\\\\standard\\\\standardScene.hap";
- var G_HAPCLSID = "CLSID:C6DC0AE5-A7BE-11D2-BDF1-0090271F4931";
- var G_HAPMimeType = "fake/mime-type";
- var G_AXCTRL = "ACTIVEHAPTEKX.ActiveHaptekXCtrl.1";
- var G_HAPVFLanguage; // Reserved for Language support
- var G_NoVF3Image;
-
- if(G_HAPVFLanguage == null)
- {
- }
- else if (G_HAPVFLanguage == "gr")
- {
- var G_HAP_LangPose = "data\\\\standard\\\\standardPose.hap";
- var G_HAP_LangScene = "data\\\\standard\\\\standardScene_gr.hap";
- var G_HAPCLSID = "CLSID:398F2883-561D-11D3-BDF1-0090272A6ABE";
- var G_HAPMimeType = "fake/mime-gr";
- var G_AXCTRL = "ACTIVEHAPTEKXGR.ActiveHaptekXCtrl.1";
- }
-
-
- ///////////////////////////////////////////////////////////////////////////////////////////
- // Detection Script
- // These routines check for the plugin, browser and platform.
-
- /////////////////
- // DETECT BROWSER
-
- MinimalVersionNN = "4.03";
- MinimalVersionIE = "4.0";
-
- G_BrowserVersion = navigator.appVersion;
- G_Platform = navigator.platform;
-
- if (navigator.appName == "Netscape") {
- navigator.plugins.refresh();
- G_BrowserNavigator = true;
- if (G_BrowserVersion < MinimalVersionNN) {
- G_BrowserOkay = false;
- G_BrowserWhyNot = "─·╡─Σ»└└╞≈╠½╛╔íú─·╓┴╔┘╨Φ╥¬ Navigator " + MinimalVersionNN + "ú¼─·╒²╘┌╩╣╙├╡─╩╟ " + G_BrowserVersion + "íú";
- }
- else
- G_BrowserOkay = true;
- }
- else {
- G_BrowserExplorer = true;
- if (G_BrowserVersion < MinimalVersionIE) {
- G_BrowserOkay = false;
- G_BrowserWhyNot = "─·╡─Σ»└└╞≈╠½╛╔íú─·╓┴╔┘╨Φ╥¬ Explorer " + MinimalVersionIE + "ú¼─·╒²╘┌╩╣╙├╡─╩╟ " + G_BrowserVersion + "íú";
- }
- else
- G_BrowserOkay = true;
- }
-
- if (G_Platform != "Win32") {
- G_PlatformOkay = false;
- G_BrowserOkay = false;
- G_BrowserWhyNot = "╒Γ╜÷╘┌ Windows 95íó98íó║═ NT ╓╨╓┤╨╨íú";
- }
-
- // END OF BROWSER DETECTION JAVASCRIPT
- // -->
- <!--
-
- ///////////////////////
- // CUSTOM ERROR HANDLER
- // This is used to supress the
- // "Automation Server can't create object"
- // message box from IE.
-
- function ErrorHandler1(msg, url, line)
- {
- if (msg == "Automation server can't create object")
- return true;
- else
- return false;
- }
-
-
- ////////////////////
- // CHECK FOR PLUGIN
- if (G_BrowserOkay && G_PlatformOkay) {
- if (G_BrowserExplorer) {
-
- //////////////////////////////////////
- // DETECT PLUGIN IN EXPLORER
- //
- G_ErrorHandlerOrig = onerror;
- onerror = ErrorHandler1;
-
- // IMPORTANT! If the following line generates an error,
- // it will indeed get "handled" by ErrorHandler1,
- // but execution of this script will terminate!
- // That is, execution will resume with the next <SCRIPT>.
-
- // Create default (error present) settings.
- G_PluginOkay = true;
- G_PluginWhyNot = "─·├╗╙╨░▓╫░ " + G_DownloadName + "íú"
- MyObject = new ActiveXObject(G_AXCTRL);
-
- if (MyObject) {
- // If the code gets past the above line,
- // we know it will also get to here.
- G_PluginOkay = true;
- delete MyObject;
- }
- else {
- // This will not ever be called.
- }
- }
- else {
- //////////////////////////////////////
- // DETECT PLUGIN IN NETSCAPE
- //
- if (navigator.plugins[G_PluginName] || navigator.plugins[G_PluginNameOld]) {
- G_PluginOkay = true;
- }
- else {
- G_PluginOkay = false;
- G_PluginWhyNot = "─·├╗╙╨░▓╫░ " + G_DownloadName + "íú"
- }
- }
- }
- else {
- G_PluginOkay = false;
- G_PluginWhyNot = "▓╗─▄╩╣╙├ VirtualFriend 3ú¼╥≥╬¬ " + G_BrowserWhyNot;
- }
-
- // END OF PLUGIN DETECTION SCRIPT
- // -->
- <!--
- // RESTORE THE OLD ERROR HANDLER.
-
- onerror = G_ErrorHandlerOrig;
-
- // -->
-